package com.cskaoyan.controller.pz;

import com.cskaoyan.bean.MallSystem;
import com.cskaoyan.bean.pz.WxSystem;
import com.cskaoyan.service.pz.ConfigService;
import com.cskaoyan.vo.BaseRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("admin/config")
public class ConfigController {

    @Autowired
    ConfigService configService;

    @RequestMapping(value = "/mall",method = RequestMethod.GET)
    public BaseRespVo listAndGet(){
        //回显商城配置信息
        MallSystem mallSystem = configService.queryMallSystem();
        return BaseRespVo.ok(mallSystem);
    }


    @RequestMapping(value = "/mall",method = RequestMethod.POST)
    public BaseRespVo listAndPost(@RequestBody MallSystem mallSystem) {
        //修改商城配置
        configService.updateMallSystem(mallSystem);
        return BaseRespVo.ok();
    }

    @RequestMapping(value = "/express",method = RequestMethod.GET)
    public BaseRespVo expressAndGet(){
        //回显运费配置信息
        Map<String, String> map = configService.queryExpress();
        return BaseRespVo.ok(map);
    }

    @RequestMapping(value = "/express",method = RequestMethod.POST)
    public BaseRespVo expressAndPost(@RequestBody Map<String, String> map){
        //修改运费配置信息
        configService.updateExpress(map);
        return BaseRespVo.ok();
    }

    @RequestMapping(value = "/order",method = RequestMethod.GET)
    public BaseRespVo orderAndGet(){
        //回显订单配置信息
        Map<String, String> map = configService.queryOrder();
        return BaseRespVo.ok(map);
    }

    @RequestMapping(value = "/order",method = RequestMethod.POST)
    public BaseRespVo orderAndPost(@RequestBody Map<String, String> map){
        //修改订单配置信息
        configService.updateOrder(map);
        return BaseRespVo.ok();
    }

    @RequestMapping(value = "/wx",method = RequestMethod.GET)
    public BaseRespVo wxAndGet(){
        //回显订单配置信息
        WxSystem wxSystem = configService.queryWx();
        return BaseRespVo.ok(wxSystem);
    }

    @RequestMapping(value = "/wx",method = RequestMethod.POST)
    public BaseRespVo wxAndPost(@RequestBody WxSystem wxSystem){
        //修改订单配置信息
        configService.updateWx(wxSystem);
        return BaseRespVo.ok();
    }



}
